#pragma once
#include "PDTExpNumUn.h"
#include "PDTNumConst.h"

class PDTNeg  :  public PDTExpNumUn, public TraverseIfc <PDTNeg , PDTNode> { public:  TRAVERSAL_IFC_IMPL(PDTNeg )
public:
  PDTNeg(PDTCodeGraph & CG, PDTExpNum &operand);

  NodeTypeEnum
  getType()
  {
    return PDTNeg_Em;
  }

  bool
  isNeg()
  {
    return true;
  }

  PDTNode *
  getOperand() const
  {
    return children[0];
  }

  virtual bool eval(PDTCodeGraph &CG)
  {
	  children[0]->eval(CG);
	  PDTNumConstInt* child = dynamic_cast<PDTNumConstInt*>(children[0]->getNValue());
	  int result = -child->getValue();
	  nValue = new PDTNumConstInt(CG, result);
	  cout<<"Negation Result of "<<child->getValue()<<": "<<result<<endl;
	  return true;
  }

	virtual PDTNode* clone(PDTCodeGraph &CG)
	{
		PDTNode* toReturn;
		PDTExpNum* childClone = (PDTExpNum*)(children[0]->clone(CG));
		toReturn = new PDTNeg(CG, *childClone);
		return toReturn;
	}

  virtual stringstream &
  toString(stringstream & ss) const
  {
    ss << "( -";
    getOperand() ->toString(ss);
    ss << ")";
    return ss;
  }

  virtual Z3_ast Z3NodeVisit (PDTZ3Visitor &ZV);
};
